while [ 1 -gt 0  ]; do
now=`date '+%s'`
echo "now:"$now

GroupPriorityLog=group_priority_log
MyPriorityLog=rfrances_priority_log
DetailedPriorityLog=detailed_priority_log
SummaryPriorityLog=summary_priority_log


if [  -f "$GroupPriorityLog" ]; then
 touch "$GroupPriorityLog"
 bhpart SHARE | head -5 >> "$GroupPriorityLog"
fi

if [  -f "$GroupPriorityLog" ]; then
 touch "$GroupPriorityLog"
fi


if [  -f "$MyPriorityLog" ]; then
 touch "$MyPriorityLog"
 bhpart SHARE | head -5 >> "$MyPriorityLog"
fi

if [  -f "$DetailedPriorityLog" ]; then
 touch "$DetailedPriorityLog"
 bhpart SHARE | head -5 >> "$DetailedPriorityLog"
fi

bhpart SHARE > lastshortlog
bhpart -r SHARE > lastlog

totalSHARES=`cat lastshortlog | tac | head --lines=-5 | tac | sed 's/  */ /g' | cut -d' ' -f 2 |  paste -sd+ - | bc`
totalPRIORITY=`cat lastshortlog | tac | head --lines=-5 | tac | sed 's/  */ /g' | cut -d' ' -f 3 |  paste -sd+ - | bc`
totalSTARTED=`cat lastshortlog | tac | head --lines=-5 | tac | sed 's/  */ /g' | cut -d' ' -f 4 |  paste -sd+ - | bc`
totalRESERVED=`cat lastshortlog | tac | head --lines=-5 | tac | sed 's/  */ /g' | cut -d' ' -f 5 |  paste -sd+ - | bc`
totalCPUTIME=`cat lastshortlog | tac | head --lines=-5 | tac | sed 's/  */ /g' | cut -d' ' -f 6 |  paste -sd+ - | bc`
totalRUNTIME=`cat lastshortlog | tac | head --lines=-5 | tac | sed 's/  */ /g' | cut -d' ' -f 7 |  paste -sd+ - | bc`

summarylinegroups=$totalSHARES" "$totalPRIORITY" "$totalSTARTED" "$totalRESERVED" "$totalCPUTIME" "$totalRUNTIME

#########################
epoch=`date`
now=`date '+%s'`
#########################
######## mine ###########
#########################
logentry=`cat lastlog | grep rfrances` 
echo $now" "$epoch >> "$MyPriorityLog"
echo $logentry >> "$MyPriorityLog"
#########################
######### groups ########
#########################
logentry=`bhpart SHARE | grep u_THEORY`
echo $now" "$epoch >> "$GroupPriorityLog"
echo $logentry >> "$GroupPriorityLog"
echo $summarylinegroups >> "$GroupPriorityLog"
#
#########################
#########################
#########################
echo $now" "$epoch >> "$DetailedPriorityLog"
sed -n '\#SHARE/u_THEORY/#,/^$/{p;}' lastlog >> "$DetailedPriorityLog"
#echo $summarylinegroups >> "$DetailedPriorityLog"
#########################
#########################
#########################


echo "done logging"
sleep 360
done
